<?php

namespace app\api\controller;
use think\Controller;
use think\Db;

class User extends Base
{
    public function __construct(){
        parent::__construct();
        $this->user=session('user');
    }

    //获取用户信息
    public function getUser()
    {
        $userInfo = session('user');
        if(!empty($userInfo)){
            $userInfo=Db::name('user')->where(['id'=>$userInfo['id']])->field('id,username,email,tel,usertype')->find();
            return result(200,'获取成功！',$userInfo);
        }else{
            return result(500,'用户未登录或登录超时，不能获取信息！');
        }
    }
}